import cv2
import os


class VideoToolBox:

    def __init__(self):
        pass

    @staticmethod
    def GetVideoTimeLong(videofilepath):
        cap = cv2.VideoCapture(videofilepath)

        ret, frame = cap.read()
        cv2.imshow("capture", frame)
        # cv2.waitKey(100000)
        print(0)
        while (1):
            ret, frame = cap.read()  # 读取一帧视频
            # ret 读取了数据就返回True,没有读取数据(已到尾部)就返回False
            # frame 返回读取的视频数据--一帧数据
            cv2.imshow("capture", frame)  # 显示视频帧
            if cv2.waitKey(40) & 0xFF == ord('q'):  # 等候40ms,播放下一帧，或者按q键退出
                break
        cap.release()  # 释放视频流
        cv2.destroyAllWindows()  # 关闭所有窗口
        return



VTB = VideoToolBox()


if __name__=="__main__":
    videofilepath = "E:\download\【机器学习】【白板推导系列】【合集1～23】_P1(系列一)绪论-资料介绍19_15.122735362.flv"
    videoobject = VTB
    videoobject.GetVideoTimeLong(videofilepath)